package com.ellricky.consultant.ui

import android.os.Bundle
import com.andr.common.ui.activity.BaseActivity
import com.andr.common.ui.mvp.BasePresenter
import com.andr.common.widget.bnb.BnbUtil
import com.andr.common.widget.bnb.OnBnbListener
import com.ellricky.baselib.BaseConstant
import com.ellricky.baselib.adapter.course.JobTrainFragment
import com.ellricky.baselib.adapter.course.JobTrainingChildFragment
import com.ellricky.baselib.cache.LocalCacheUtil
import com.ellricky.baselib.ui.SchoolOverviewFragment
import com.ellricky.baselib.ui.clue.MyClueFragment
import com.ellricky.baselib.ui.order.OrderManagerFragment
import com.ellricky.baselib.ui.reserve.ReserveListFragment
import com.ellricky.baselib.util.EAppUtil
import com.ellricky.consultant.R
import kotlinx.android.synthetic.main.ct_activity_main.*

class ConsultantMainActivity : BaseActivity<Void, BasePresenter<Void>>(), OnBnbListener {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        LocalCacheUtil.setIsReloadData(true)
    }


    override fun onPause() {
        super.onPause()
        LocalCacheUtil.setIsReloadData(false)
    }

    override fun getContentLayout(): Int {
        return R.layout.ct_activity_main
    }

    override fun initUIView() {
        val iconShowBundle = Bundle().apply {
            putBoolean(BaseConstant.KEY_SHOW_BACK, true)
        }
        mainView.initVP(
            listOf(
                MyClueFragment.newInstance(),
                ReserveListFragment.newInstance(),
                JobTrainFragment(),
                OrderManagerFragment.newInstance(iconShowBundle),
                SchoolOverviewFragment.newInstance(),
            ), supportFragmentManager
        )

        mainView.initBnb(
            mutableListOf(
                BnbUtil.addBnbItem(
                    this,
                    R.drawable.ct_icon_my_clue_sel,
                    R.drawable.ct_icon_my_clue_nor,
                    R.string.base_my_clue
                ),
                BnbUtil.addBnbItem(
                    this,
                    R.drawable.ct_icon_reserve_sel,
                    R.drawable.ct_icon_reserve_nor,
                    R.string.base_class_manage
                ),

                BnbUtil.addBnbItem(
                    this,
                    R.drawable.ct_icon_mytask_sel,
                    R.drawable.ct_icon_mytask_nor,
                    R.string.base_job_training_title
                ),

                BnbUtil.addBnbItem(
                    this,
                    R.drawable.base_icon_rank_sel,
                    R.drawable.base_icon_rank_nor,
                    R.string.base_order_manager
                ),
                BnbUtil.addBnbItem(
                    this,
                    R.drawable.base_icon_integral_sel,
                    R.drawable.base_icon_integral_nor,
                    R.string.base_my_achievement
                ),
            )
        )

        mainView.setOnBnbListener(this)
    }



    override fun onSelectTab(p0: Int): Boolean {
        when (p0) {
            1 -> {
                EAppUtil.jumpClassManage(this)
                return false
            }
        }
        return true
    }

    override fun onKeyBack(isKeyBack: Boolean) {
        EAppUtil.exitApp(this)
    }
}
